<?php
use yii\bootstrap\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\LinkPager;

?>
<style>
    .table input[type="text"] {padding-left: 0;}
    @media (max-width: 1280px){
        .table > thead > tr > th{padding: 8px;}
        .tab_form input[type="text"],
        .tab_form .select{width: 98px;}
    }

</style>
<div class="row">
    <div class="container lh30">
        <a class="topNav" href="<?= Url::toRoute('/system/site/index') ?>" style=""><img
                src="<?= Yii::getAlias('@web/backend/img/home/home.png'); ?>" alt="首页"/>返回首页</a>
    </div>
</div>

<div class="row nav-brand-bg borB">
    <div class="container lh30">
        <ul class="nav nav-tabs">
            <li class="active"><a href="<?= Url::toRoute(['repertory/repertorymanage']) ?>" style="">库存管理</a></li>
            <li><a href="<?= Url::toRoute(['repertoryinc/storage', 'type' => 1]) ?>" style="">商品入库</a></li>
            <li><a href="<?= Url::toRoute(['goodsdec/repertoryout', 'type' => 1]) ?>">商品出库</a></li>
            <li><a href="<?= Url::toRoute(['repertoryinc/increcord']) ?>">入库流水</a></li>
            <li><a href="<?= Url::toRoute(['goodsdec/decrecord']) ?>">出库流水</a></li>
        </ul>
    </div>
</div>


<div class="container">
    <div class="mg20-y lh45 clearfix" style=" word-spacing: -6px;">
        <?php if ($this->userinfo->user_type == 3) { ?>
        <a class="check btnBg dis text-center lh45 mr20" href="javascript:;"><img
                src="<?= Yii::getAlias('@web/backend/img/stocks/iconfont-xiugaikucun.png'); ?>" alt=""
                style="margin-right: 9px;"/><span>库存盘点</span></a>
        <?php } ?>
        <a class="btnBg dis text-center lh45" href="<?= Url::toRoute(['repertory/exportexcel']) ?>"><img
                src="<?= Yii::getAlias('@web/backend/img/stocks/excel.png'); ?>" alt=""
                style="margin-right: 9px;vertical-align: text-top;"/>导出EXCEL</a>
    </div>
    <div class="lh45">
        <form class="tab_form" role="form" action="" method="get">
            <?php if ($this->userinfo->user_type == 4) { ?>
                <span>供应商</span>
                <input class="lh45" type="text" name="supplier_name" value="<?= Html::encode($supplier_name) ?>"/>
                <span class="mg20-x">品牌</span>
                <input class="lh45" type="text" name="repertory_brand" value="<?= Html::encode($repertory_brand) ?>"/>
            <?php } ?>
            <span>商品名称</span><input class="lh45" type="text" name="repertory_name" value="<?= Html::encode($repertory_name) ?>"/><span class="mg20-x">排序方式</span>

            <div class="select lh45">
                <select name="order">
                    <option value="-10000" <?php if ($order == -10000){ ?>selected="selected"<?php } ?>>默认</option>
                    <option value="1" <?php if ($order == 1){ ?>selected="selected"<?php } ?>>以库存由少到多</option>
                </select>
            </div><span class="mg20-x">分类</span><div class="select lh45">
                <select name="is_familly" id="">
                    <option value="-10000" <?php if ($is_familly == -10000){ ?>selected="selected"<?php } ?>>全部</option>
                    <option value="1" <?php if ($is_familly == 1){ ?>selected="selected"<?php } ?>>家居产品</option>
                </select>
            </div>
            <a class="btnBg  pull-right" style="width: 75px; color: #fff;border-radius: 6px;">
                <input type="submit" value="搜索" style="display: block; width: 100%; background: 0;line-height: 36px; font-size: 17px;">
            </a>
        </form>
    </div>

    <div class="table-responsive">
        <?php if(empty($data)){?>
        <table class="table table-bordered mt20">
            <thead>
                <tr>
                    <th>商品名称</th>
                    <th>规格</th>
                    <th>库存</th>
                    <th>供应商</th>
                    <!-- 店长 -->
                    <?php if ($this->userinfo->user_type == 4) { ?>
                    <th>零售价</th>
                    <?php } ?>
                    <th>品牌</th>
                    <th>系列</th>
                    <th>类别</th>
                    <!-- 老板 -->
                    <?php if ($this->userinfo->user_type == 3) { ?>
                    <th>成本价</th>
                    <th>零售价</th>
                    <?php } ?>
                    <th>条形码</th>
                    <th>是否家居</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td <?php if($this->userinfo->user_type == 4){?>colspan="11"<?php }else{?>colspan="12"<?php }?>  align="center"><img src="<?=Yii::getAlias('@web/backend/img/nodata.gif');?>"></td>
                </tr>
            </tbody>
        </table>
        <?php }else{?>
        <table class="table table-bordered mt20" style="table-layout: fixed">
            <thead>
                <tr>
                    <th>商品名称</th>
                    <th>规格</th>
                    <th>库存</th>
                    <th>供应商</th>
                    <!-- 店长 -->
                    <?php if ($this->userinfo->user_type == 4) { ?>
                        <th>零售价</th>
                    <?php } ?>
                    <th>品牌</th>
                    <th>系列</th>
                    <th>类别</th>
                    <!-- 老板 -->
                    <?php if ($this->userinfo->user_type == 3) { ?>
                        <th>成本价</th>
                        <th>零售价</th>
                    <?php } ?>
                    <th>条形码</th>
                    <th>是否家居</th>
                    <th style="width: 180px;">操作</th>
                </tr>
            </thead>
            <tbody>
            <?php foreach ($data as $d) { ?>
                <tr>
                    <?php ActiveForm::begin(['action' => Url::toRoute('repertory/edit')]) ?>
                    <input class="repertory_id " type="hidden" name="repertory_id"
                           value="<?= Html::encode($d['repertory_id']) ?>" readonly/>
                    <td><input class="repertory_name read-only text_repertory" type="text" name="repertory_name"
                               value="<?= Html::encode($d['repertory_name']) ?>" readonly/></td>
                    <td>
                        <div class="select hideBox hidden select_repertory">
                          <select class="" name="repertory_specs">
                            <option value=""></option>
                            <?php foreach ($specs as $sp) { ?>
                                <option value="<?= Html::encode($sp->config_val) ?>"
                                        <?php if ($d['repertory_specs'] == $sp->config_val){ ?>selected="selected"<?php } ?>><?= Html::encode($sp->config_val) ?></option>
                            <?php } ?>
                        </select>
                        </div>
                        <input class="showBox read-only" type="text" name="" value="<?= Html::encode($d['repertory_specs']) ?>" readonly/>
                    </td>
                    <td><input class="repertory_count read-only text_repertory" type="text" name="repertory_count"
                               value="<?= Html::encode($d['repertory_count']) ?>" readonly/></td>
                    <td>
                        <div class="select hideBox hidden select_repertory">
                        <select class="hideBox hidden" name="supplier_name">
                            <option value=""></option>
                            <?php foreach ($supplier as $su) { ?>
                                <option value="<?= Html::encode($su->config_val) ?>"
                                        <?php if ($d['supplier_name'] == $su->config_val){ ?>selected="selected"<?php } ?>><?= Html::encode($su->config_val) ?></option>
                            <?php } ?>
                        </select>
                        </div>
                        <input class="showBox read-only" type="text" name=""
                               value="<?= Html::encode($d['supplier_name']) ?>" readonly/>
                    </td>
                    <!-- 店长 -->
                    <?php if ($this->userinfo->user_type == 4) { ?>
                        <td><?= Html::encode($d['goods_sell_price']) ?></td>
                    <?php } ?>
                    <td>
                        <div class="select hideBox hidden select_repertory">
                        <select class="" name="repertory_brand">
                            <option value=""></option>
                            <?php foreach ($brand as $br) { ?>
                                <option value="<?= Html::encode($br->config_val) ?>"
                                        <?php if ($d['repertory_brand'] == $br->config_val){ ?>selected="selected"<?php } ?>><?= Html::encode($br->config_val) ?></option>
                            <?php } ?>
                        </select>
                        </div>
                        <input class="showBox read-only" type="text" name=""
                               value="<?= Html::encode($d['repertory_brand']) ?>" readonly/>
                    </td>
                    <td>
                        <div class="select hideBox hidden select_repertory">
                            <select class="" name="repertory_series">
                                <option value=""></option>
                                <?php foreach ($series as $se) { ?>
                                    <option value="<?= Html::encode($se->config_val) ?>"
                                            <?php if ($d['repertory_series'] == $se->config_val){ ?>selected="selected"<?php } ?>><?= Html::encode($se->config_val) ?></option>
                                <?php } ?>
                            </select>
                        </div>
                            <span class="">
                            <input class="showBox read-only" type="text" name=""
                                   value="<?= Html::encode($d['repertory_series']) ?>" readonly/>
                            </span>
                    </td>
                    <td>
                        <div class="select hideBox hidden select_repertory">
                            <select class=" " name="repertory_category">
                                <option value=""></option>
                                <?php foreach ($category as $ca) { ?>
                                    <option value="<?= Html::encode($ca->config_val) ?>"
                                            <?php if ($d['repertory_category'] == $ca->config_val){ ?>selected="selected"<?php } ?>><?= Html::encode($ca->config_val) ?></option>
                                <?php } ?>
                            </select>
                        </div>
                        <input class="showBox  read-only" type="text" name=""
                               value="<?= Html::encode($d['repertory_category']) ?>" readonly/>
                    </td>
                    <!-- 老板 -->
                    <?php if ($this->userinfo->user_type == 3) { ?>
                        <td><input class="read-only text_repertory" type="text" name="goods_cost_price"
                                   value="<?= Html::encode($d['goods_cost_price']) ?>" readonly/></td>
                        <td><input class="read-only text_repertory" type="text" name="goods_sell_price"
                                   value="<?= Html::encode($d['goods_sell_price']) ?>" readonly/></td>
                    <?php } ?>
                    <td><input class="read-only text_repertory" type="text" name="bar_code" value="<?= Html::encode($d['bar_code']) ?>"
                               readonly/></td>
                    <td>
                        <div class="select hideBox hidden select_repertory">
                        <select class="" name="is_sell">
                            <option value="1" <?php if ($d['is_sell'] == 1){ ?>selected="selected"<?php } ?>>是</option>
                            <option value="0" <?php if ($d['is_sell'] == 0){ ?>selected="selected"<?php } ?>>否</option>
                        </select>
                        </div>
                        <input class="showBox read-only" type="text" name=""
                               value="<?php if ($d['is_sell'] == 0) { ?>否<?php } ?><?php if ($d['is_sell'] == 1) { ?>是<?php } ?>"
                               readonly/>
                    </td>
                    <td><input class="hidden" type="submit"/><a class="edit btn btn-sm btn-borB4" href="javascript:;">编辑</a></td>
                </tr>
                <?php ActiveForm::end(); ?>
            <?php } ?>


            </tbody>
        </table>
    </div>

    <div class="page">
        <?= LinkPager::widget([
            'pagination' => $page,
            'firstPageLabel' => '首页',
            'nextPageLabel' => '下一页',
            'prevPageLabel' => '上一页',
            'lastPageLabel' => '末页',
        ]); ?>
    </div>
    <?php }?>
</div>


<?php $this->registerJsFile("@web/system/repertory/repertorymanage.js", ['position' => $this::POS_END]); ?>

</body>
</html>

